import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from config import HOST
from api import log
class ApiApproveTrust:
    def __init__(self, session):
        self.session = session 
        self.__url_approve = HOST + "/member/realname/approverealname"
        self.__url_api_approve_status = HOST + "/member/member/getapprove"
        self.__url_api_trust = HOST + "/trust/trust/register"
        self.__url_api_img_code = HOST + "/common/public/verifycode1/{}"
        self.__url_api_recharge = HOST + "/trust/trust/recharge"
        pass
    #认证接口
    def api_approve(self, realname = "张三", card_id = "130432200305047466"):
        data = {
            "realname":realname,
            "card_id":card_id,
            } 
        #这里用的是multipart/form-data multipart 多消息体
        return self.session.post( self.__url_approve, data=data, files={"x":"y"}) #files：上传文件的参数,这里再传一个参自动变成multipart
    #查询认证接口
    def api_approve_status(self,  realname = "张三", card_id ="130432200305047466"): 
        data = {
            "realname":realname,
            "card_id":card_id,
            } 
        return self.session.post(self.__url_api_approve_status, data=data)

    #开户接口
    def api_trust(self):
        return self.session.post(self.__url_api_trust)

    #获取图片验证码接口
    def api_img_code(self,random):
        return self.session.get(self.__url_api_img_code.format(random))
    #充值接口
    def api_recharge(self, valicode):
        data = {
            "paymentType":"chinapnrTrust",
            "amount":"1000",
            "formStr":"reForm",
            "valicode":valicode,
            } 
        return self.session.post(self.__url_api_recharge, data=data)
  
